package com.Maykk.bytesStream;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @ClassName: com.Maykk.bytesStream.Demo05
 * @Description: TODO 复制图片
 * @Author: MaykkStar@163.com
 */
public class Demo05 {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("input.jpg");
//        FileOutputStream fos = new FileOutputStream("output.jpg");
        FileOutputStream fosNew = new FileOutputStream("outputNew.jpg");

        // 一边读一边写

//        int a;
//        while ((a = fis.read()) != -1) {
//            fos.write(a);
//        } // 每次写 1 字节

//        byte[] bytes = new byte[1024];
//        int len;
//        while ((len = fis.read(bytes)) != -1) {  // fis.read(bytes) 把读取到的字节写入 bytes 数组中
//            fosNew.write(bytes, 0, len);
//        } // 每次写 1k

        fis.close();
//        fos.close();
        fosNew.close();
    }
}
